package DAY1209.Demo2;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.util.List;

/**
 * @Author:LiRegin
 * @Date: 2019/12/9 16:43:17
 */
public class Test {
    public static void main(String[] args) throws DocumentException {
        SAXReader reader = new SAXReader();
        Document dom=reader.read(new File("C:\\XML\\src\\DAY1209\\Demo2\\cars.xml"));
        Element root = dom.getRootElement();
        List<Element> servletList = root.elements("VALUE");
        for(Element servlet:servletList){
            List<Element> elements=servlet.elements();
            for (Element element : elements) {
                if (element.getName().equals("NO")) {
                    System.out.println("车牌号码:" + element.attributeValue("DATE"));
                }else if (element.getName().equals("ADDR")){
                    System.out.println("车主地址:"+element.getText());
                }
            }
        }
    }
}
